const initialState = {
  channels: [],
  list: [],
  total: 0,
};

export const article = (state = initialState, action) => {
  // 频道列表
  if (action.type === 'article/getChannels') {
    // 创建新对象，覆盖频道列表数据
    return {
      ...state,
      channels: action.payload,
    };
  }
  // 文章列表
  if (action.type === 'article/getArticles') {
    // console.log(action.payload);
    // return {
    //   ...state,
    //   ...action.payload
    // }
    // 和上面等价
    return {
      ...state,
      list: action.payload.list,
      total: action.payload.total,
    };
  }

  return state;
};
